package config.externalized;


import config.auto.My2ConfigurationProperties;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

@Component
public class MyBean {

    // 这样可以读取到配置文件中的值{name: 123}
    // 也可以能通过启动命令时添加启动参数 java -jar --name=123来设置
    @Value("${name}")
    private String name = "myBeanName";

    private final My2ConfigurationProperties my2ConfigurationProperties;

    public MyBean ( My2ConfigurationProperties my2ConfigurationProperties ) {
        this.my2ConfigurationProperties = my2ConfigurationProperties;
    }

    public String getName ( ) {
        return name;
    }

    public void setName ( String name ) {
        this.name = name;
    }

    public My2ConfigurationProperties getMy2ConfigurationProperties ( ) {
        return my2ConfigurationProperties;
    }
}
